import os.path

from milvus.milvus_op import MilvusOP
from preprocess.preprocess_data import image_saved_dir

config = {'ns': 1, 'ts': 1, 'e': 1, 'td': 0.5}
milvus_op = MilvusOP(db_name='state_vector_db', collection_name="hybrid2")
while True:
    a = input('Input: ')
    search_df = milvus_op.hybrid_search([a], limit=5, config=config)
    for i in search_df:
        print('-' * 45, i['id'], '-' * 45)
        file_name = i['name'] + i['type']
        print(i['score'], i['remark'])
        if len(i['image_path']) > 0:
            image_path = os.path.join(image_saved_dir, i['image_path'])
            print(image_path)
        print(f'\033[91m{file_name}\033[0m')
        print(i['text'])
    print('_' * 99)
